import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/Home.vue'
import Details from '@/views/Details.vue'
import Explain from '@/views/Explain.vue'
import Vote from '@/views/Vote.vue'
import Report from '@/views/Report.vue'
import Member from '@/views/Member.vue'
import Roster from '@/views/Roster.vue'
import Review from '@/views/Review.vue'
import Tour from '@/views/Tour.vue'
import People from '@/views/People.vue'
import Upload from '@/views/Upload.vue'
import BookSearch from '@/views/BookSearch.vue'
import buildDetails from '@/components/build-details/index.vue'
const _this = new Vue()
Vue.use(VueRouter)
const routes = [
  {
    path: '/',
    name: 'Home',
    meta: {
      pid: 0,
      name: '首页',
    },
    component: Home,
  },
  {
    path: '/details',
    name: 'Details',
    meta: {
      pid: 0,
      name: '大赛详情',
    },
    component: Details,
  },
  {
    path: '/BookSearch',
    name: 'bookSearch',
    meta: {
      pid: 1,
      name: '查询结果',
    },
    component: BookSearch,
  },
  {
    path: '/explain',
    name: 'Explain',
    meta: {
      pid: 0,
      name: '奖项说明',
    },
    component: Explain,
  },
  {
    path: '/vote',
    name: 'Vote',
    meta: {
      pid: 0,
      name: '参赛人投票',
    },
    component: Vote,
  },
  {
    path: '/report',
    name: 'Report',
    meta: {
      pid: 0,
      name: '大赛报道',
    },
    component: Report,
  },
  {
    path: '/member',
    name: 'Member',
    meta: {
      pid: 0,
      name: '执行委员会',
    },
    component: Member,
  },
  {
    path: '/roster',
    name: 'Roster',
    meta: {
      pid: 0,
      name: '往届名单',
    },
    component: Roster,
  },
  {
    path: '/review',
    name: 'Review',
    meta: {
      pid: 0,
      name: '往期回顾',
    },
    component: Review,
  },
  {
    path: '/tour',
    name: 'Tour',
    meta: {
      pid: 0,
      name: '城市巡演',
    },
    component: Tour,
  },
  {
    path: '/people',
    name: 'People',
    meta: {
      pid: 1,
      name: '参赛人物',
    },
    component: People,
  },
  {
    path: '/Upload',
    name: 'Upload',
    meta: {
      pid: 1,
      name: '上传文件',
    },
    component: Upload,
  },
  {
    path: '/newsDetails',
    name: 'newsDetails',
    meta: {
      pid: 1,
      name: '新闻详情',
    },
    component: buildDetails,
  },
]
const router = new VueRouter({
  mode: 'history',
  routes,
})
router.beforeEach(async (to, from, next) => {
  _this.load()
  next()
  _this.done()
})
export default router
